package com.ruoyi.labdata.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabFlowTaskLog;
import com.ruoyi.labdata.service.ILabFlowTaskLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * taskLogController
 * 
 * @author winner pan
 * @date 2022-03-26
 */
@RestController
@RequestMapping("/labdata/taskLog")
public class LabFlowTaskLogController extends BaseController
{
    @Autowired
    private ILabFlowTaskLogService labFlowTaskLogService;

    /**
     * 查询taskLog列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabFlowTaskLog labFlowTaskLog)
    {
        startPage();
        List<LabFlowTaskLog> list = labFlowTaskLogService.selectLabFlowTaskLogList(labFlowTaskLog);
        return getDataTable(list);
    }

    /**
     * 导出taskLog列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:export')")
    @Log(title = "taskLog", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabFlowTaskLog labFlowTaskLog)
    {
        List<LabFlowTaskLog> list = labFlowTaskLogService.selectLabFlowTaskLogList(labFlowTaskLog);
        ExcelUtil<LabFlowTaskLog> util = new ExcelUtil<LabFlowTaskLog>(LabFlowTaskLog.class);
        return util.exportExcel(list, "taskLog");
    }

    /**
     * 获取taskLog详细信息
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return AjaxResult.success(labFlowTaskLogService.selectLabFlowTaskLogById(logId));
    }

    /**
     * 新增taskLog
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:add')")
    @Log(title = "taskLog", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabFlowTaskLog labFlowTaskLog)
    {
        return toAjax(labFlowTaskLogService.insertLabFlowTaskLog(labFlowTaskLog));
    }

    /**
     * 修改taskLog
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:edit')")
    @Log(title = "taskLog", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabFlowTaskLog labFlowTaskLog)
    {
        return toAjax(labFlowTaskLogService.updateLabFlowTaskLog(labFlowTaskLog));
    }

    /**
     * 删除taskLog
     */
    //@PreAuthorize("@ss.hasPermi('labdata:taskLog:remove')")
    @Log(title = "taskLog", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(labFlowTaskLogService.deleteLabFlowTaskLogByIds(logIds));
    }
}
